<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
        const arr = ['red', 'green', 'blue'];
        for(let v of arr) {
            console.log(v); // red green blue
        }

        // for...of循环本质上就是调用iterator接口产生的遍历器
        const obj = {};
        obj[Symbol.iterator] = arr[Symbol.iterator].bind(arr);
        for(let v of obj) {
            console.log(v); // red green blue
        }

        // for...in循环读取键名，for...of循环读取键值
        var arr1 = ['a', 'b', 'c', 'd'];
        for (let a in arr1) {
            console.log(a); // 0 1 2 3
        }

        for (let a of arr1) {
            console.log(a); // a b c d
        }

    </script>

</head>
<body>

</body>
</html>